<?xml version='1.0' encoding='UTF-8' ?>
        <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
        xmlns:my='http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-14T10:15:01'>
        <xsl:output method='xml' standalone='yes' />
        <xsl:template match='my:myFields'>
        <DynamicEntity Name='csp_buildingpermit' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
        xmlns:xsd='http://www.w3.org/2001/XMLSchema' >
        <Properties xmlns='http://schemas.microsoft.com/crm/2006/WebServices'>

		<xsl:if test='//my:CitizenAddress/text()'>
			<Property xsi:type='StringProperty' Name='csp_address'>
				<Value><xsl:value-of select='//my:CitizenAddress'/></Value>
			</Property>
		</xsl:if>

		<xsl:if test='//my:CitizenCity/text()'>
			<Property xsi:type='StringProperty' Name='csp_city'>
				<Value><xsl:value-of select='//my:CitizenCity'/></Value>
			</Property>
		</xsl:if>

		<xsl:if test='//my:CitizenZip/text()'>
			<Property xsi:type='StringProperty' Name='csp_postalcode'>
				<Value><xsl:value-of select='//my:CitizenZip'/></Value>
			</Property>
		</xsl:if>

		<xsl:if test='//my:CitizenEmail/text()'>
			<Property xsi:type='StringProperty' Name='csp_emailaddress'>
				<Value><xsl:value-of select='//my:CitizenEmail'/></Value>
			</Property>
		</xsl:if>

		<xsl:if test='//my:CitizenPhone/text()'>
			<Property xsi:type='StringProperty' Name='csp_phone'>
				<Value><xsl:value-of select='//my:CitizenPhone'/></Value>
			</Property>
		</xsl:if>

		<xsl:if test='//my:CitizenFax/text()'>
			<Property xsi:type='StringProperty' Name='csp_fax'>
				<Value><xsl:value-of select='//my:CitizenFax'/></Value>
			</Property>
		</xsl:if>

        <xsl:if test='//my:PropertyBuildingSize/text()'>
        <Property xsi:type='CrmFloatProperty' Name='csp_buildingsize'>
          <Value><xsl:value-of select='//my:PropertyBuildingSize'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ContractorAddress/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractoraddress'>
          <Value><xsl:value-of select='//my:ContractorAddress'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ContractorCity/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractorcity'>
          <Value><xsl:value-of select='//my:ContractorCity'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ContractorName/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractorname'>
          <Value><xsl:value-of select='//my:ContractorName'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ContractorZIP/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractorpostalcode'>
          <Value><xsl:value-of select='//my:ContractorZIP'/></Value>
        </Property>
        </xsl:if>
					
        <xsl:if test='//my:ContractorPhone/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractorphone'>
          <Value><xsl:value-of select='//my:ContractorPhone'/></Value>
        </Property>
        </xsl:if>

				<xsl:if test='//my:ContractorEmail/text()'>
        <Property xsi:type='StringProperty' Name='csp_contractoremail'>
          <Value><xsl:value-of select='//my:ContractorEmail'/></Value>
        </Property>
        </xsl:if>					

        <xsl:if test='//my:PropertyLotNumber/text()'>
        <Property xsi:type='StringProperty' Name='csp_lotnumber'>
          <Value><xsl:value-of select='//my:PropertyLotNumber'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:PropertyLotSize/text()'>
        <Property xsi:type='CrmFloatProperty' Name='csp_lotsize'>
          <Value><xsl:value-of select='//my:PropertyLotSize'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ProjectEndDate/text()'>
        <Property xsi:type='CrmDateTimeProperty' Name='csp_procedureenddate'>
          <Value><xsl:value-of select='//my:ProjectEndDate'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ProjectStartDate/text()'>
        <Property xsi:type='CrmDateTimeProperty' Name='csp_procedurestartdate'>
          <Value><xsl:value-of select='//my:ProjectStartDate'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ProjectCost/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_projectcost'>
          <Value><xsl:value-of select='//my:ProjectCost'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:ProjectSize/text()'>
        <Property xsi:type='CrmFloatProperty' Name='csp_projectsize'>
          <Value><xsl:value-of select='//my:ProjectSize'/></Value>
        </Property>
        </xsl:if>
					
        <xsl:if test='//my:PermitAmount/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_permitamount'>
          <Value><xsl:value-of select='//my:PermitAmount'/></Value>
        </Property>
        </xsl:if>

				<xsl:if test='//my:ProjectType/text()'>
				<Property xsi:type='PicklistProperty' Name='csp_projecttype'>
					<xsl:choose>
					<xsl:when test="//my:ProjectType='New building'"><Value>1</Value></xsl:when>
					<xsl:when test="//my:ProjectType='Garage'"><Value>2</Value></xsl:when>
					<xsl:when test="//my:ProjectType='House enhancement'"><Value>3</Value></xsl:when>
					<xsl:when test="//my:ProjectType='New floor'"><Value>4</Value></xsl:when>
					<xsl:otherwise><Value>100</Value></xsl:otherwise>
					</xsl:choose>
				</Property>
				</xsl:if>

        <xsl:if test='//my:PropertyAddress/text()'>
        <Property xsi:type='StringProperty' Name='csp_propertyaddress'>
          <Value><xsl:value-of select='//my:PropertyAddress'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:PropertyCity/text()'>
        <Property xsi:type='StringProperty' Name='csp_propertycity'>
          <Value><xsl:value-of select='//my:PropertyCity'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:PropertyZIP/text()'>
        <Property xsi:type='StringProperty' Name='csp_propertypostalcode'>
          <Value><xsl:value-of select='//my:PropertyZIP'/></Value>
        </Property>
        </xsl:if>

        <xsl:if test='//my:PropertyTax/text()'>
        <Property xsi:type='CrmMoneyProperty' Name='csp_propertytax'>
          <Value><xsl:value-of select='//my:PropertyTax'/></Value>
        </Property>
        </xsl:if>
					
</Properties></DynamicEntity></xsl:template></xsl:stylesheet>
